const arr = [
    {
        id: 4,
        parent_id: 1,
        node_type: 0,
        label: '菜单管理',
        path: '/sys/menu',
        sort: 103,
        icon: 'el-icon-menu',
        isable: 1,
    },
    {
        id: 2,
        parent_id: 1,
        node_type: 0,
        label: '角色管理',
        path: '/sys/role',
        sort: 102,
        icon: 'el-icon-setting',
        isable: 1,
    },
    {
        id: 3,
        parent_id: 1,
        node_type: 0,
        label: '用户管理',
        path: '/sys/user',
        sort: 101,
        icon: 'el-icon-user',
        isable: 1,
    },
    {
        id: 1,
        parent_id: 0,
        node_type: 0,
        label: '系统管理',
        path: '/main_sys',
        sort: 100,
        icon: 'el-icon-setting',
        isable: 1,
    },
    {
        id: 8,
        parent_id: 5,
        node_type: 0,
        label: 'Banner',
        path: '/shop/banner',
        sort: 99,
        icon: '',
        isable: 1,
    },
    {
        id: 7,
        parent_id: 5,
        node_type: 0,
        label: '商品分类',
        path: '/shop/category',
        sort: 98,
        icon: 'el-icon-camera',
        isable: 1,
    },
    {
        id: 6,
        parent_id: 5,
        node_type: 0,
        label: '商品管理',
        path: '/shop/goods',
        sort: 97,
        icon: 'el-icon-s-order',
        isable: 1,
    },
    {
        id: 10,
        parent_id: 5,
        node_type: 0,
        label: '订单管理',
        path: '/shop/order',
        sort: 95,
        icon: '',
        isable: 1,
    },
    {
        id: 9,
        parent_id: 5,
        node_type: 0,
        label: '会员管理',
        path: '/shop/member',
        sort: 94,
        icon: '',
        isable: 1,
    },
    {
        id: 5,
        parent_id: 0,
        node_type: 0,
        label: '商城系统',
        path: '/main_shop',
        sort: 90,
        icon: 'el-icon-goods',
        isable: 1,
    },
    {
        id: 12,
        parent_id: 0,
        node_type: 0,
        label: 'OA办公系统',
        path: '/main_oa',
        sort: 80,
        icon: 'el-icon-box',
        isable: 1,
    },
    {
        id: 16,
        parent_id: 0,
        node_type: 0,
        label: '万声音乐',
        path: '/main_ws',
        sort: 70,
        icon: 'el-icon-service',
        isable: 1,
    },
    {
        id: 38,
        parent_id: 0,
        node_type: 0,
        label: '图库',
        path: '/tk',
        sort: 1,
        icon: null,
        isable: 1,
    },
    {
        id: 13,
        parent_id: 12,
        node_type: 0,
        label: '员工管理',
        path: '/user/list',
        sort: 1,
        icon: '',
        isable: 1,
    },
    {
        id: 17,
        parent_id: 16,
        node_type: 0,
        label: '音乐管理',
        path: '/music/list',
        sort: 1,
        icon: '',
        isable: 1,
    },
    {
        id: 40,
        parent_id: 38,
        node_type: 0,
        label: '风景图',
        path: '/fj/list',
        sort: 1,
        icon: null,
        isable: 1,
    },
    {
        id: 37,
        parent_id: 5,
        node_type: 0,
        label: '商家管理',
        path: '/shop/store',
        sort: 1,
        icon: '',
        isable: 1,
    },
    {
        id: 14,
        parent_id: 12,
        node_type: 0,
        label: '日志管理',
        path: '/log/list',
        sort: 1,
        icon: '',
        isable: 1,
    },
    {
        id: 18,
        parent_id: 16,
        node_type: 0,
        label: '歌手管理',
        path: '/singer/list',
        sort: 1,
        icon: '',
        isable: 1,
    },
    {
        id: 39,
        parent_id: 5,
        node_type: 0,
        label: '商家地图',
        path: '/shop/mp',
        sort: 1,
        icon: null,
        isable: 1,
    },
    {
        id: 15,
        parent_id: 12,
        node_type: 0,
        label: '日志回复',
        path: '/reply/list',
        sort: 1,
        icon: '',
        isable: 1,
    },
    {
        id: 19,
        parent_id: 16,
        node_type: 0,
        label: '歌单管理',
        path: '/song/list',
        sort: 1,
        icon: '',
        isable: 1,
    },
]

const getThreeMenu = (rootList,id,menuList)=>{
    rootList.forEach(item=>{
        if(item.parent_id === id){
            menuList.push(item)
        }
    })

    menuList.forEach(item=>{
        item.children = []
        getThreeMenu(rootList,item.id,item.children)
        if(item.children.length === 0){
            delete item.children
        }
    })
    return menuList
}

const menuList = getThreeMenu(arr,0,[])
console.log(menuList);